package com.zhoukun.nacos.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.zhoukun.cloud.CommentRest;
import com.zhoukun.nacos.myfallback.CustomeeFallback;
import com.zhoukun.nacos.myhandler.CustomerBlockHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhoukun 86547462@qq.com
 * @version 1.0
 * @date 2020/11/1 23:55
 */

@RestController
@Slf4j
/**
 * 1.系统默认的，没有体现出我们自己的业务要求
 * 2.依照现有条件，自定义方法和业务代码耦合在一起，不直观
 * 3.每一个方法都有兜底的方法，引起代码膨胀
 * 4.全局统一的方法没有体现
 */
public class globalController {

    @GetMapping("/globlHandler1")
    @SentinelResource(value = "globlHandler1",
            blockHandlerClass = CustomerBlockHandler.class,blockHandler = "globlHandler1",
            fallbackClass = CustomeeFallback.class,fallback = "globlfallback1")
    public CommentRest get1() {

            throw new RuntimeException("测试======》");

    }

    @GetMapping("/globlHandler2")
    @SentinelResource(value = "globlHandler2",blockHandlerClass = CustomerBlockHandler.class,blockHandler = "globlHandler2",
            fallbackClass = CustomeeFallback.class,fallback = "globlfallback2")
    public CommentRest  get2() {
        return new CommentRest().setMessage("success");
    }
}
